// src/main/java/com/example/daibanshiwu/Service/Impl/PersonalCenterServiceImpl.java
package com.example.daibanshiwu.Service.Impl;

import com.example.daibanshiwu.Service.PersonalCenterService;
import com.example.daibanshiwu.mapper.PersonalCenterMapper;
import com.example.daibanshiwu.pojo.PasswordChangeDTO;
import com.example.daibanshiwu.pojo.TUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PersonalCenterServiceImpl implements PersonalCenterService {

    // 【推荐】使用构造器注入代替字段注入
    private final PersonalCenterMapper personalCenterMapper;

    public PersonalCenterServiceImpl(PersonalCenterMapper personalCenterMapper) {
        this.personalCenterMapper = personalCenterMapper;
    }

//    @Override
//    public List<TUser> getUserInfo(Integer userId) {
//        // 直接调用Mapper层的方法获取数据，现在返回的是List
////        return personalCenterMapper.findById(userId);
//    }

    @Override
    @Transactional
    public void updateUserProfile(TUser user) {
        // 此方法逻辑不受影响
        personalCenterMapper.updateProfile(user);
    }

    @Override
    @Transactional
    public void changeUserPassword(TUser user) {
//    TUser user=personalCenterMapper.findById(userId);
    personalCenterMapper.updatePassword(user.getUserId(),user.getPassword(),user.getNewPassword());

    }
}
